
#include "tcpa_monitor.h"

int tcpam_proc_status(FILE *fd, void *user_data)
{
    tcpa_monitor_t *monitor = (tcpa_monitor_t *)user_data;
    fprintf(fd, "---tcp acceleration monitor[%s] status---\n", TCPA_MONITOR_VERSION);
    fprintf(fd, "login_status[%d] g_bnn_id[%d] tcpa_ctrl_num[%d] rule_num[%d]\n", monitor->login_status, monitor->pep_svn_info.now_g_bnn_id, monitor->tcpa_ctrl_node_num, monitor->rule_node_num);

    tcpa_ctrl_t *tcpa_ctrl = NULL;
    list_for_each_entry(tcpa_ctrl, &monitor->tcpa_ctrl_list, node) {
        fprintf(fd, "vrfname[%s], tcpa_pid["PRINTF_UINT64_FORMAT"] restart_cnt[%u] \n", tcpa_ctrl->vrf_name, tcpa_ctrl->tcpa_pid, tcpa_ctrl->tcpa_restart_cnt);
    }
    return 0;
}


int tcpam_proc_tcpa_cfg(FILE *fd, void *user_data)
{
    tcpa_monitor_t *monitor = (tcpa_monitor_t *)user_data;

    tcpa_ctrl_t *tcpa_ctrl = NULL;
    list_for_each_entry(tcpa_ctrl, &monitor->tcpa_ctrl_list, node) {
        tcpa_cfg_t *cfg = &tcpa_ctrl->tcpa_cfg;
        fprintf(fd, "---tcpa: vrfname[%s]---\n", tcpa_ctrl->vrf_name);
        fprintf(fd, "vrf%u, tcpa_enable[%u], max_connect[%u], server_ip_str[%s], server_port[%u], listen_port[%u]\n", 
                    cfg->vrf_id, cfg->tcpa_enable, cfg->max_connect, cfg->server_ip_str, cfg->server_port, cfg->listen_port);
    }

    return 0;
}

int tcpam_proc_whitelist_cfg(FILE *fd, void *user_data)
{
    tcpa_monitor_t *monitor = (tcpa_monitor_t *)user_data;

    rule_cfg_t *rule = NULL;
    list_for_each_entry(rule, &monitor->rule_list, node) {
        fprintf(fd, "---vrf id[%d]---\n", rule->vrf_id);
        fprintf(fd, "src_ip_str[%s], src_port[%d], dst_ip_str[%s], dst_port[%d]\n", 
                    rule->src_ip_str, rule->src_port, rule->dst_ip_str, rule->dst_port);
    
    }

    return 0;
}